package com.ryzx.common.response;

public enum BapResultCode {
    /* 参数错误：1000～1999 */
    PARAM_NOT_VALID(1001, "参数无效"),
    PARAM_IS_BLANK(1002, "参数为空"),
    PARAM_TYPE_ERROR(1003, "参数类型错误"),
    PARAM_NOT_COMPLETE(1004, "参数缺失"),

    /* 用户错误 */
    USER_NOT_LOGIN(2001, "用户未登录"),
    USER_ACCOUNT_EXPIRED(2002, "账号已过期"),
    USER_CREDENTIALS_ERROR(2003, "密码错误"),
    USER_CREDENTIALS_EXPIRED(2004, "密码过期"),
    USER_ACCOUNT_DISABLE(2005, "账号不可用"),
    USER_ACCOUNT_LOCKED(2006, "账号被锁定"),
    USER_ACCOUNT_NOT_EXIST(2007, "账号不存在"),
    USER_ACCOUNT_ALREADY_EXIST(2008, "账号已存在"),
    USER_ACCOUNT_USE_BY_OTHERS(2009, "账号下线"),


    /* 用户文件错误 */
    FILE_IS_BLANK(3001, "文件不存在"),
    TYPE_CASTING_ERROR(3002, "类型转换错误"),
    FILE_COMPRESS_ERROR(3003, "文件压缩失败"),

    /* 业务错误 */
    NO_PERMISSION(4001, "没有权限"),
    FILE_TRANS_ERROR(4002, "文件传输错误"),
    DATA_DEPENDENCY_ERROR(4003, "数据依赖错误"),
    POST_LEVEL_NOT_SET(4003, "未设置领导岗位"),

    /* */
    DATABASE_COLUMN_READ_ERROR(5001, "字段读取错误"),
    DATABASE_COLUMN_TYPE_VALID(5002, "字段类型无效"),


    COMMUNICATION_FAIL(6001,"通讯失败"),
    COMMUNICATION_TIMEOUT(6002,"通讯超时"),

    /* 成功 */
    SERVER_ERROR(500,"服务器错误"),
    SERVER_BUSY(501,"服务器忙"),
    SUCCESS(200, "成功");
    private Integer code;
    private String message;

    BapResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessageByCode(Integer code) {
        for (BapResultCode ele : values()) {
            if (ele.getCode().equals(code)) {
                return ele.getMessage();
            }
        }
        return null;
    }
}
